package org.bp.spider.util;

import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Map;

/**
 * @author baiping
 * @version 1.0
 * @date 2017/9/6
 */
public class CollectionsUtils {

    public static boolean isAbsEmpty(Object obj) {
        if(obj == null) {
            return true;
        } else if(obj instanceof Collection) {
            Collection<?> map1 = (Collection<?>) obj;
            return map1.size() == 0;
        } else if(obj instanceof Map) {
            Map<?, ?> map = (Map<?, ?>)obj;
            return map.size() == 0;
        } else if(obj.getClass().isArray()) {
            return Array.getLength(obj) == 0;
        } else {
            throw new RuntimeException("not support this type");
        }
    }
    public static boolean isNotAbsEmpty(Object obj) {
        return !isAbsEmpty(obj);
    }
}
